package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {

    /**
     * 按照类型查询分类
     * @param list
     * @return
     */
    @Select("select * from category where type = #{list}")
    List<Category> get (Integer list);

    /**
     * 根据id查询分类
     * @param id
     * @return
     */
    @Select("select * from category where id = #{id}")
    Category selectById(Long id);

    /**
     * @description 分类条件查询
     * @param categoryPageQueryDTO
     * @return
     * @author yunfeng
     * @date 2023/5/5 10:29:38
     */
    Page<Category> selectByPage(CategoryPageQueryDTO categoryPageQueryDTO);

    /**
     * @description 新增分类信息
     * @param category
     * @return
     * @author yunfeng
     * @date 2023/5/5 10:50:21
     */
    @Insert("insert into category values(null,#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void insert(Category category);


    /**
     * @description 根据分类类型查询分类信息
     * @param
     * @return
     * @author yunfeng
     * @date 2023/5/5 11:06:29
     */
    List<Category> selectByType(Integer type);


    /**
     * @description 修改分类
     * @param category
     * @return
     * @author yunfeng
     * @date 2023/5/5 11:24:15
     */
    void update(Category category);

    /**
     * @description 删除分类信息
     * @param id
     * @return
     * @author yunfeng
     * @date 2023/5/5 12:18:37
     */
    @Delete("delete from category where id = #{id}")
    void delete(Long id);
}
